<!--
 * @Version: 1.0
 * @Date: 2021-04-25 14:54:43
 * @LastEditTime: 2021-04-29 14:28:20
 * @Description:物流付款单详情
-->
<template>
  <div v-loading="loadingInfo">
    <el-form :model="formData" inline label-width="150px">
      <div class="header_title_box">
        <h2 style="margin-right:50px">
          基本信息
        </h2>
      </div>
      <el-row :gutter="20">
        <el-col :span="8">
          <el-form-item label="付款单号：">
            <span>{{ formData.payment_no }}</span>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="货代公司：">
            <span>{{ formData.lforwarder_company }}</span>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="应付金额(USD)：">
            <span>{{ formData.order_amount }}</span>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="实际付款日期：">
            <span>{{ formData.pay_time ? formData.pay_time : '-' }}</span>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="实际付款金额：">
            <span>{{ formData.pay_amount !== '0' ? formData.pay_amount : '-' }}</span>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="审核状态：">
            <span>{{ statusData[formData.audit_status+''] }}</span>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="申请状态：">
            <span>{{ formData.pay_status === 0 ? '待付款' : '已付款' }}</span>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div>
      <div class="header_title_box">
        <h2 style="margin-right:50px">
          付款单明细
        </h2>
      </div>
      <div>
        <el-table
          ref="multipleTable"
          :data="transportList"
          tooltip-effect="dark"
          style="width: 100%"
          border
        >
          <el-table-column align="center" label="提单号" prop="bl_no" width="170" />
          <el-table-column align="center" label="柜号" prop="cabinet_no" width="150" />
          <el-table-column align="center" label="装柜日期" prop="loading_date" width="150" />
          <el-table-column align="center" label="起运日期" prop="shipment_date" width="150" />
          <el-table-column align="center" label="预计到仓日期" prop="arrive_date" width="150" />
          <el-table-column align="center" label="所属货代公司" prop="lforwarder_company" />
          <el-table-column align="center" label="货代公司结算周期(天)" prop="settlement_cycle" width="150" />
          <el-table-column align="center" label="付款单号" prop="payment_no" width="150" />
          <el-table-column align="center" label="申请付款状态" prop="pay_status">
            <template slot-scope="scope">
              {{ scope.row.pay_status===1 ? '已申请': '待申请' }}
            </template>
          </el-table-column>
          <el-table-column align="center" label="国内路运费用" prop="domestic_fee" />
          <el-table-column align="center" label="海运费用" prop="ocean_fee" width="150" />
          <el-table-column align="center" label="国外路运费用" prop="overseas_fee" width="160" />
          <el-table-column align="center" label="应付金额" prop="total_fee">
            <template slot-scope="scope">
              {{ accAddFuc(accAddFuc(scope.row.ocean_fee, scope.row.overseas_fee ), scope.row.domestic_fee) }}
            </template>
          </el-table-column>
          <el-table-column align="center" label="预计付款时间" prop="estimated_pay_time" width="150" />
        </el-table>
      </div>
    </div>
  </div>
</template>
<script>
import { accAdd } from '@/utils/index.js'
export default {
  name: 'LogisticsInfo',
  props: {
    id: {
      type: String,
      default: ''
    },
    formData: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
    //   formData: {},
      loadingInfo: false,
      statusData: {
        '0': '待审核',
        '1': '审核通过',
        '-1': '审核驳回'
      },
      transportList: []
    }
  },
  created() {
    this.loadingInfo = true
    this.orderInfo()
  },
  methods: {
    accAddFuc(val1, val2) {
      return accAdd(val1, val2)
    },
    orderInfo() {
      this.$http.get(`/freight-bill?payment_no=${this.id}`, { params: { limit: 1000, page: 1 }}).then((res) => {
        if (res.code === 10000) {
          const dataArr = res.data
          this.transportList = dataArr
          this.loadingInfo = false
        }
      }).catch(() => {
        this.loadingInfo = false
      })
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
